using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace Rdpk
{
    public static class RWDev
    {
        [DllImport("RR3WinCE.dll")]
        public static extern int ConnectReader( );

        [DllImport("RR3WinCE.dll")]
        public static extern int DisconnectReader();

        [DllImport("RR3WinCE.dll")]
        public static extern int Inventory(byte address,
                                           byte state,
                                           byte AFI,
                                           byte[] DSFIDAndUID,
                                           ref byte CardNum);

        [DllImport("RR3WinCE.dll")]
        public static extern int StayQuiet(byte address,
                                           byte[] UID);

        [DllImport("RR3WinCE.dll")]
        public static extern int ReadSingleBlock(byte address,
                                                 byte state,
                                                 byte[] UID,
                                                 byte blockNumber,
                                                 ref byte securityWord,
                                                 byte[] Data);

        [DllImport("RR3WinCE.dll")]
        public static extern int ReadMultipleBlock(byte address,
                                                   byte state,
                                                   byte[] UID,
                                                   byte startBlock,
                                                   byte numberOfBlock,
                                                   byte[] securityWord,
                                                   byte[] Data);

        [DllImport("RR3WinCE.dll")]
        public static extern int WriteSingleBlock(byte address,
                                                  byte state,
                                                  byte[] UID,
                                                  byte blockNumber,
                                                  byte[] Data);

        [DllImport("RR3WinCE.dll")]
        public static extern int LockBlock(byte address,
                                           byte state,
                                           byte[] UID,
                                           byte BlockNumber);

        [DllImport("RR3WinCE.dll")]
        public static extern int Select(byte address,
                                        byte[] UID);

        [DllImport("RR3WinCE.dll")]
        public static extern int Ready(byte address,
                                       byte state,
                                       byte[] UID);

        [DllImport("RR3WinCE.dll")]
        public static extern int WriteAFI(byte address,
                                          byte state,
                                          byte[] UID,
                                          byte AFI);

        [DllImport("RR3WinCE.dll")]
        public static extern int LockAFI(byte address,
                                         byte state,
                                         byte[] UID);

        [DllImport("RR3WinCE.dll")]
        public static extern int WriteDSFID(byte address,
                                            byte state,
                                            byte[] UID,
                                            byte DSFID);

        [DllImport("RR3WinCE.dll")]
        public static extern int LockDSFID(byte address,
                                           byte state,
                                           byte[] UID);

        [DllImport("RR3WinCE.dll")]
        public static extern int GetTagInfo(byte address,
                                            byte state,
                                            byte[] UIDI,
                                            ref byte InformationFlag,
                                            byte[] UIDO,
                                            ref byte DSFID,
                                            ref byte AFI,
                                            byte[] MemorySize,
                                            ref byte ICReference);

        [DllImport("RR3WinCE.dll")]
        public static extern int GetReaderInfo(ref byte address,
                                               byte[] versionInfo,
                                               ref byte model,
                                               byte[] supProtocol,
                                               ref byte inventoryScanTime);

        [DllImport("RR3WinCE.dll")]
        public static extern int ChangeTo14443A(byte address);

        [DllImport("RR3WinCE.dll")]
        public static extern int ChangeTo14443B(byte address);

        [DllImport("RR3WinCE.dll")]
        public static extern int ChangeTo15693(byte address);

/************************************************************
        [DllImport("RR3WinCE.dll")]
        public static extern int SetLED(byte address,
                                        byte openTime,
                                        byte closeTime,
                                        byte repeat);
        [DllImport("RR3WinCE.dll")]
        public static extern int SetBeep(byte address,
                                         byte OpenTime,
                                         byte CloseTime,
                                         byte Repeat);
************************************************************/
        [DllImport("RR3WinCE.dll")]
        public static extern int OpenRF(byte address);

        [DllImport("RR3WinCE.dll")]
        public static extern int CloseRF(byte address);

        [DllImport("RR3WinCE.dll")]
        public static extern int WriteReaderAddr( byte address,
                                                  byte newAddr);

        [DllImport("RR3WinCE.dll")]
        public static extern int WriteInventoryScanTime(byte address,
                                                        byte inventoryScanTime);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443ARequest(byte address,
                                                  byte requestMode,
                                                  byte[] cardtype,
                                                  ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AAnticoll(byte address,
                                                   byte[] UID,
                                                   ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AAnticoll2(byte address,
                                                    byte enColl,
                                                    byte[] UID,
                                                    ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AULAnticoll(byte address,
                                                     byte[] UID,
                                                     ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443ASelect(byte address,
                                                 byte[] UID,
                                                 ref byte capacityCode,
                                                 ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AAuthentication(byte address,
                                                         byte keyType,
                                                         byte sector,
                                                         ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AAuthentication2(byte address,
                                                          byte keyType,
                                                          byte sector,
                                                          byte keySector,
                                                          ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AAuthKey(byte address,
                                                  byte keyType,
                                                  byte sector,
                                                  byte[] key,
                                                  ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AHalt(byte address,
                                               ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443ARead(byte address,
                                               byte blockNumber,
                                               byte[] data,
                                               ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AWrite(byte address,
                                                byte blockNumber,
                                                byte[] data,
                                                ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AULWrite(byte address,
                                                  byte pageNumber,
                                                  byte[] data,
                                                  ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AInitValue(byte address,
                                                    byte blockNumber,
                                                    byte[] initValue,
                                                    ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AReadValue(byte address,
                                                    byte blockNumber,
                                                    byte[] Value,
                                                    ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AIncrement(byte address,
                                                    byte blockNumber,
                                                    byte[] incValue,
                                                    ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443ADecrement(byte address,
                                                    byte blockNumber,
                                                    byte[] decValue,
                                                    ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443ARestore(byte address,
                                                  byte blockNumber,
                                                  ref byte errorCode);


        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443ATransfer(byte address,
                                                   byte blockNumber,
                                                   ref byte errorCode);


        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443ALoadKey(byte address,
                                                  byte keyType,
                                                  byte keySector,
                                                  byte[] key,
                                                  ref byte errorCode);


        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443ACheckWrite(byte address,
                                                     byte[] UID,
                                                     byte keyType,
                                                     byte blockNumber,
                                                     byte[] data,
                                                     ref byte errorCode);


        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AReadE2(byte address,
                                                 byte E2PROMAddr,
                                                 byte bytesToRead,
                                                 byte[] data,
                                                 ref byte errorCode);


        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AWriteE2(byte address,
                                                  byte E2PROMAddr,
                                                  byte bytesToWrite,
                                                  byte[] data,
                                                  ref byte errorCode);


        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443AValue(byte address,
                                                byte operationMode,
                                                byte srcBlockNumber,
                                                byte[] value,
                                                byte destBlockNumber,
                                                ref byte errorCode);


        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443BRequestNoAFI(byte address,
                                                       byte requestMode,
                                                       byte[] PUPI,
                                                       byte[] applicationData,
                                                       byte[] protocolInfo,
                                                       ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443BRequestWithAFI(byte address,
                                                         byte requestMode,
                                                         byte AFI,
                                                         byte[] PUPI,
                                                         byte[] applicationData,
                                                         byte[] protocolInfo,
                                                         ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443BAnticollNoAFI(byte address,
                                                       byte anticollMode,
                                                       byte[] PUPI,
                                                       byte[] applicationData,
                                                       byte[] protocolInfo,
                                                       ref byte errorCode);

        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443BAnticollWithAFI(byte address,
                                                         byte anticollMode,
                                                         byte AFI,
                                                         byte[] PUPI,
                                                         byte[] applicationData,
                                                         byte[] protocolInfo,
                                                         ref byte errorCode);
        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443BSelect(byte address,
                                                 byte[] PUPI,
                                                 byte CIDI,
                                                 byte param1,
                                                 byte param2,
                                                 byte param3,
                                                 byte param4,
                                                 ref byte CIDO,
                                                 ref byte MBLI,
                                                 ref byte errorCode);


        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443BHalt(byte address,
                                               byte[] PUPI,
                                               ref byte errorCode);


        [DllImport("RR3WinCE.dll")]
        public static extern int ISO14443BTransparentCmd(byte address,
                                                         byte timeM,
                                                         byte timeN,
                                                         byte cmdLength,
                                                         byte rspLength,
                                                         byte[] cmdData,
                                                         byte[] rspData,
                                                         ref byte errorCode);
    }
}


